//
//  LGFriendCitangViewController.m
//  ligenyun
//
//  Created by Mac on 2018/4/10.
//  Copyright © 2018年 stoneobs@icloud.com. All rights reserved.
//

#import "LGFriendCitangViewController.h"
#import "UICollectionView+STNoresult.h"
#import "LGOtherCitangCollectionViewCell.h"
@interface LGFriendCitangViewController ()<UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout>
@property(nonatomic, strong) UICollectionView                     *collectionView;
@property(nonatomic, strong) NSMutableArray                     *dataSouce;
@end

@implementation LGFriendCitangViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"ta的祠堂";
    [self configSubView];
    // Do any additional setup after loading the view.
}
#pragma mark --subView
- (void)configSubView{
    UICollectionViewFlowLayout * flow = [UICollectionViewFlowLayout new];
    flow.scrollDirection = UICollectionViewScrollDirectionVertical;
    flow.minimumLineSpacing = 10;
    flow.minimumInteritemSpacing = 10;
    flow.sectionInset = UIEdgeInsetsMake(0, 15, 0, 15);
    
    self.collectionView = [[UICollectionView alloc] initWithFrame:UIScreenFrame collectionViewLayout:flow];
    self.collectionView.delegate = self;
    self.collectionView.dataSource = self;
    self.collectionView.backgroundColor = TM_backgroundColor;
    [self.collectionView registerClass:[LGOtherCitangCollectionViewCell class] forCellWithReuseIdentifier:@"item"];
    [self.view addSubview:self.collectionView];
    
    self.collectionView.st_noreslutView = [[STNoresultView alloc] initWithFrame:CGRectMake(0, 100, 300, 300) title:@"暂无祠堂" buttonTitle:@"" buttonHandle:^(NSString *titleString) {
        
    }];
    self.collectionView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
        [self sendGemeterListRequest];
    }];
    [self.collectionView.mj_header beginRefreshing];
}
#pragma --mark UICollectionViewDataSource
-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
    return 1;
}
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return self.dataSouce.count;
}
-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
     CGFloat itemWith = (UIScreenWidth - 30 - 10)/2;
     return CGSizeMake(itemWith,[LGOtherCitangCollectionViewCell itemHeight]);
}
-(UICollectionViewCell*)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    LGOtherCitangCollectionViewCell * item =[collectionView dequeueReusableCellWithReuseIdentifier:@"item" forIndexPath:indexPath];
    return item;
}
#pragma --mark UICollectionViewDelegate
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    
    [self.collectionView deselectItemAtIndexPath:indexPath animated:NO];
}
#pragma mark --NetWork Method
- (void)sendGemeterListRequest{
    [TMUtils debugSimulationNetWorkWithHadle:^(NSInteger afterTime) {
        self.dataSouce = [@[@"",@"",@"",@"",@"",@"",@"",@""] mutableCopy];
        [self.collectionView.mj_header endRefreshing];
        [self.collectionView reloadData];
    }];
}
@end
